{#
    Combo box for choosing an existing gradeable as a template for the new one
        (Only show this option if we aren't in edit mode).
#}
{% if action == 'new' or action == 'template' %}
    <div>
    {# temporarily remove the template feature because it is stale / needs refactoring.
        <div class="option row">
            <div class="option-desc col-md-6">
                <label for="gradeable_template">
                    <div class="option-title">Template</div>
                    <div class="option-alt">Select from one of the templates</div>
                </label>
            </div>
            <div class="option-input col-md-6">
                <select name="gradeable_template" id="gradeable_template" style='margin-right:30px'>
                <option>--None--</option>
                {% for template in template_list %}
                <option {{ action != 'new' and gradeable.getId() == template.g_id ? 'selected' : '' }}
                    value="{{ template.g_id }}">{{ template.g_title }}</option>
                {% endfor %}
                </select>
            </div>
        </div>
    #}
    </div>

{% endif %}

{#
    Primary Form
#}
<!-- Gradeable Title (read/write in all modes) -->
    <div class="option row">
        <div class="option-desc col-md-6">
            <label for="g_title">
                <div class="option-title">Title</div>
                <div class="option-alt">What is the title of this gradable?</div>
                <p id="required_type">(Required)</p>
            </label>
        </div>

        <div class="option-input col-md-6">
            <textarea onkeyup="textAreaAdjust(this)" name='title' id='g_title' class="required auto_save" style="overflow:hidden" placeholder="(Required)" required>{{action != 'new' ? gradeable.getTitle() : '' }}</textarea>
        </div>
    </div>


<!-- Instruction URL (read/write in all modes) -->
<div class="option row">
    <div class="option-desc col-md-6">
        <label for="instructions_url">
            <div class="option-title">Assignment URL</div>
            <div class="option-alt">What is the URL to the assignment instructions? (shown to student)</div>
        </label>
    </div>
    <div class="option-input col-md-6">
        <input type='text' name='instructions_url' id='instructions_url' class="auto_save"
        value="{{ action != 'new' ? gradeable.getInstructionsUrl() : '' }}" placeholder="(Optional)" />
    </div>
</div>


<!-- Gradeable ID (readonly in edit mode, required) -->
<div class="option row">
    <div class="option-desc col-md-6">
        <label for="g_id">
            <div class="option-title">Unique ID</div>
            <div class="option-alt">What is the unique id of this gradeable? (e.g., <kbd>hw01</kbd>, <kbd>lab_12</kbd>, or <kbd>midterm</kbd>)</div>
        </label>
    </div>
    <div class="option-input col-md-6">
        <input type='text' name='id' id="g_id" class="required"
        value="{{ action != 'new' ? gradeable.getId() : '' }}" placeholder="(Required)"
        {{ action == 'edit' ? 'readonly' : 'required' }} />
    </div>
</div>

<div class="option">
    <div class="option-desc col-md-12">
        {% if action == 'new' or action == 'template' %}
            <!-- Gradeable Type radio buttons (readonly in edit mode) -->
            {# (VPAT) fieldset/legend required for gradeable type container radio group #}
            <fieldset><legend><div class="option-title">Gradeable Type</div></legend>
            <div class="option-alt"><a target=_blank href="http://submitty.org/instructor/create_edit_gradeable#types-of-gradeables">What is the type of the gradeable <i style="font-style:normal;" class="fa-question-circle"></i></a></div>
            <span id="required_type" >(Required)</span>
        {% else %}
            <b style='font-size:18px'>Gradeable type</b>: <span id="gradeable-type-string">{{ type_string }}</span>
            <br />
        {% endif %}
        <div id="gradeable_type_container" {{ action == 'edit' ? 'hidden' : '' }}>
            <div>
                <input type='radio' id="radio_checkpoints" name="type" value="Checkpoints"
                    {{ action != 'new' and gradeable.getType() == 1 ? 'checked' : '' }}> <label for="radio_checkpoints"> {{ gradeable_type_strings['checkpoint'] }} </label>
            </div>

            <div>
                <input type='radio' id="radio_numeric" name="type" value="Numeric"
                    {{ action != 'new' and gradeable.getType() == 2 ? 'checked' : '' }}> <label for="radio_numeric"> {{ gradeable_type_strings['numeric'] }} </label>
            </div>

            <div aria-hidden="true" hidden>
                <input type='radio' id="radio_electronic_file" name="type" value="Electronic File"
                        {{ action != 'new' and gradeable.getType() == 0 ? 'checked' : '' }}> Electronic File (multiple types)
            </div>

            {# Real input fields to back the exposed configurations options #}
            <div aria-hidden="true" hidden>
                <input id="scanned_exam" name="scanned_exam" value="{{ action != 'new' and gradeable.isScannedExam() ? 'true' : 'false' }}">
                <input id="vcs" name="vcs" value="{{ action != 'new' and gradeable.isVcs() ? 'true' : 'false' }}">
            </div>

            <div>
                <input class="ignore" type="radio" id="radio_ef_student_upload" name="electronic_gradeable_presets" value="normal"
                        {{ action != 'new' and not gradeable.isScannedExam() and not gradeable.isVcs() ? 'checked' : ''}}> <label for="radio_ef_student_upload"> {{ gradeable_type_strings['electronic_hw'] }} </label>
            </div>

            <div>
                <input class="ignore" type="radio" id="radio_ef_vcs_upload" name="electronic_gradeable_presets" value="vcs"
                        {{ action != 'new' and not gradeable.isScannedExam() and gradeable.isVcs() ? 'checked' : ''}}> <label for="radio_ef_vcs_upload"> {{ gradeable_type_strings['electronic_hw_vcs'] }} </label>
            </div>

            <div>
                <input class="ignore" type="radio" id="radio_ef_scanned_exam" name="electronic_gradeable_presets" value="scanned_exam"
                        {{ action != 'new' and gradeable.isScannedExam() ? 'checked' : '' }}> <label for="radio_ef_scanned_exam"> {{ gradeable_type_strings['electronic_exam'] }} </label>
            </div>
        </div>
        {% if action == 'new' or action == 'template' %}
            {# (VPAT) Closes fieldset that was opened for the gradeable type container radio group #}
            </fieldset>
        {% endif %}

      <!-- This is only relevant to Electronic Files -->
        <div class="gradeable_type_options electronic_file" id="electronic_file">
            <fieldset>
                <legend>Will any or all of this assignment be manually graded (e.g., by the TAs or the instructor)?</legend>
                <input type="radio" id="yes_ta_grade" name="ta_grading" value="true" class="bool_val auto_save date-related"
                        {{ action != 'new' and gradeable.getTaGrading() ? 'checked' : '' }} /> <label for="yes_ta_grade">Yes</label>
                <input type="radio" id="no_ta_grade" name="ta_grading" value="false" class="bool_val auto_save date-related"
                        {{ not (action != 'new' and gradeable.getTaGrading()) ? 'checked' : '' }} /> <label for="no_ta_grade">No</label>
            </fieldset>

            {% if regrade_enabled %}
                <fieldset id="regrade_request_enable_container">
                    <legend>Should grade inquiries be enabled for this assignment?</legend>
                    <input type="radio" id="yes_regrade_allowed" name="regrade_allowed" value="true" class="bool_val auto_save date-related"
                            {{ action != 'new' and gradeable.isRegradeAllowed() ? 'checked' : '' }} /> <label for="yes_regrade_allowed">Yes</label>
                    <input type="radio" id="no_regrade_allowed" name="regrade_allowed" value="false" class="bool_val auto_save date-related"
                            {{ not (action != 'new' and gradeable.isRegradeAllowed()) ? 'checked' : '' }} /> <label for= "no_regrade_allowed">No</label>
                </fieldset>

                <fieldset class="grade_inquiry_per_component_allowed" id="gi_component_enable_container">
                    <legend>Should grade inquiries be associated with a specific component of the rubric?</legend>
                    <input type="radio" id="yes_grade_inquiry_per_component_allowed" name="grade_inquiry_per_component_allowed" value="true" class="bool_val auto_save"
                            {{ gradeable.isGradeInquiryPerComponentAllowed() ? 'checked' : '' }} /> <label for="yes_grade_inquiry_per_component_allowed">Yes</label>
                    <input type="radio" id="no_grade_inquiry_per_component_allowed" name="grade_inquiry_per_component_allowed" value="false" class="bool_val auto_save"
                            {{ not gradeable.isGradeInquiryPerComponentAllowed() ? 'checked' : '' }} /> <label for= "no_grade_inquiry_per_component_allowed">No</label>
                </fieldset>
            {% endif %}

            {% if forum_enabled %}
                <div>
                    <fieldset id="discussion_grading_enable_container">
                        <legend>Is there a discussion component for this assignment?</legend>
                        <input type="radio" id="yes_discussion" name="discussion_based" value="true" class="bool_val auto_save date-related"
                                {{ action != 'new' and gradeable.isDiscussionBased() ? 'checked' : '' }} /> <label for="yes_discussion">Yes</label>
                        <input type="radio" id="no_discussion" name="discussion_based" value="false" class="bool_val auto_save date-related"
                                {{ not (action != 'new' and gradeable.isDiscussionBased()) ? 'checked' : '' }} /> <label for="no_discussion">No</label>
                    </fieldset>
                    <div class="discussion_id_wrapper">
                        <label for="discussion_thread_id">What thread id(s) should be included? (separate by commas)</label>
                            <input style="width: 70px" name="discussion_thread_id" id="discussion_thread_id" class="int_val auto_save" type="text"
                                   value="{{ action != 'new' ? gradeable.getStringThreadIds() : '' }}"/>
                    </div>
                </div>
            {% endif %}

            <div id="team-settings-container">
                {% if action == 'new' or action == 'template' %}
                    {# (VPAT) fieldset/legend needed for team assignment radio group #}
                    <fieldset><legend>Is this a team assignment?</legend>
                {% else %}
                    Team Settings:
                    {{ gradeable.isTeamAssignment() ? '' : ' This is an individual assignment' }}
                {% endif %}
                <div style="{{ action == 'edit' ? 'display:none' : '' }}">
                    <input type="radio" id = "team_yes_radio" name="team_assignment" value="true"
                            {{ action != 'new' and gradeable.isTeamAssignment() ? 'checked' : '' }}> <label for="team_yes_radio">Yes</label>

                    <input type="radio" id = "team_no_radio" name="team_assignment" value ="false"
                            {{ not (action != 'new' and gradeable.isTeamAssignment()) ? 'checked' :  '' }}> <label for="team_no_radio">No</label>
                </div>
                {% if action == 'new' or action == 'template' %}
                    {# (VPAT) Closes fieldset for team assignment radio group #}
                    </fieldset>
                {% endif %}
            </div>

            <!-- Team settings (read only in edit mode) -->
            <div class="team_assignment team_yes" id="team_yes">

                <label for="team_size_max">What is the maximum team size?</label>
                    <input style="width: 50px" name="team_size_max" id="team_size_max" class="int_val auto_save" type="text"
                           value="{{ action != 'new' ? gradeable.getTeamSizeMax() : '3' }}"/>

                {#Use teams from a previous gradeable:
                <!-- Inherit teams from another gradeable? -->
                <br />
                    <!--Use a combo box if we can edit the value, otherwise show a text box (readonly)-->
                {% if action == 'new' %}
                    <select id='gradeable_teams' name="eg_inherit_teams_from" style='width: 170px;'
                        value='{{ admin_gradeable.getEgInheritTeamsFrom() }}'>
                        <option value=''>--None--</option>
                        {% for parent in inherit_teams_list %}
                            <option {{ admin_gradeable.getEgInheritTeamsFrom() == parent.g_id ? 'selected' : '' }}
                                value="{{ parent.g_id }}">{{ parent.g_title }}</option>
                        {% endfor %}
                    </select>
                {% else %}
                    <input id='gradeable_teams_read' name='gradeable_teams_read' style='width=170px'
                        value='{{ admin_gradeable.getEgInheritTeamsFrom() }}' readonly/>
                {% endif %}
                #}
            </div>

            <div id="repository">
                <fieldset>
                    <legend>VCS Repository Details (select one)</legend>
                    <div>
                        <input type='radio' id="vcs_radio_submitty_hosted" name="vcs_radio_buttons" value="submitty-hosted"
                            {{ action == 'new' or (action != 'new' and gradeable.getVcsHostType() == 0) ? 'checked' : '' }}
                            {{ action != 'new' and action != 'template' ? 'disabled' : '' }}> <label for="vcs_radio_submitty_hosted">Submitty hosted – single gradeable repository</label>

                        <div id="vcs_submitty_url_content" name="vcs_content" style="margin-left: 5%">
                            <kbd id="vcs_url">{{ vcs_base_url }}&#123;&#36;gradeable_id&#125;&#47;</kbd>
                            <kbd class="team_no">&#123;&#36;user_id&#125;</kbd>
                            <kbd class="team_yes">&#123;&#36;team_id&#125;</kbd>
                        </div>
                    </div>
                    <div class="team_no">
                        <input type='radio' id="vcs_radio_submitty_hosted_set_url" name="vcs_radio_buttons" value="submitty-hosted-url"
                            {{ action != 'new' and gradeable.getVcsHostType() == 1 ? 'checked' : '' }}
                            {{ action != 'new' and action != 'template' ? 'disabled' : '' }}> <label for="vcs_radio_submitty_hosted_set_url">Submitty hosted – choose repository name (can be used for multiple gradeables)</label>

                        <div id="vcs_submitty_set_url_content" name="vcs_content" style="margin-left: 5%">
                            {% if action == 'new' or action == 'template' %}
                                <kbd id="vcs_url">{{ vcs_base_url }}</kbd>
                                <input style='width: 30%' type='text' name="vcs_url" id="vcs_submitty_url" class="required auto_save" placeholder="(Required)"
                                    aria-label="repository name" value="" required />
                                <kbd id="vcs_url2">&#47;&#123;&#36;user_id&#125;</kbd>
                            {% else %}
                                <kbd id="vcs_url">{{ gradeable.getVcsSubdirectory() }}</kbd>
                            {% endif %}
                        </div>
                    </div>

                    <input type='radio' id="vcs_radio_public_github" name="vcs_radio_buttons" value="public-github"
                        {{ action != 'new' and gradeable.getVcsHostType() == 2 ? 'checked' : '' }}
                        {{ action != 'new' and action != 'template' ? 'disabled' : '' }}> <label for="vcs_radio_public_github">Github hosted - public repository, students will provide URL</label> </br>

                    <input type='radio' id="vcs_radio_private_github" name="vcs_radio_buttons" value="private-github"
                        {{ action != 'new' and gradeable.getVcsHostType() == 3 ? 'checked' : '' }}
                        {{ action != 'new' and action != 'template' ? 'disabled' : '' }}> <label for="vcs_radio_private_github">Github hosted - private repository, students will provide URL (NOTE: INCOMPLETE -- DO NOT USE)</label>
                </fieldset>
            </div>
        </div>
    </div>
</div>

<!-- Gradeable bucket (read/write in all modes) -->
<div class="option row">
    <div class="option-desc col-md-6">
        <label for="syllabus_bucket">
            <div class="option-title">Syllabus Category</div>
            <div class="option-alt"><a target=_blank href="https://submitty.org/instructor/rainbow_grades/gradeables">What syllabus category does this item belong to? <i style="font-style:normal;" class="fa-question-circle"></i></a></div>
        </label>
    </div>

    <div class="option-input col-md-6">
        <select name="syllabus_bucket" id="syllabus_bucket" class="auto_save">
        {% for bucket in syllabus_buckets %}
        <option value="{{ bucket }}" {{ action != 'new' and gradeable.getSyllabusBucket() == bucket ? 'selected' : '' }}>
            {{ bucket | title }}
        </option>
        {% endfor %}
        </select>
    </div>
</div>

{% if action == 'new' or action == 'template' %}
<div class="option row">
    <div class="option-desc col-md-12">
        <em>Note: After pressing the "Create New Gradeable" button you may not change:</em>
        <ul style="margin-left:10px">
            <li style="margin-left:15px"><em>The unique id</em></li>
            <li style="margin-left:15px"><em>Gradeable type (electronic file upload, checkpoints, or text)</em></li>
            <li style="margin-left:15px"><em>Whether the students will submit as individuals or team</em></li>
            <li style="margin-left:15px"><em>Whether the students will submit by directly uploading files or by version control</em></li>
        </ul>
        <em>All other settings for this gradeable may be edited.</em>
    </div>
</div>
<div class="row">
    <input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
    <button class="btn btn-primary" type="submit" style="margin-left:10px;">Create New Gradeable</button>
</div>
{% endif %}


<div id="alert-message" title="WARNING">
    <p>Gradeable ID must not be blank and only contain characters <strong> a-z A-Z 0-9 _ - </strong> </p>
</div>

<script type="text/javascript">


    /* Increasing Height of textarea*/
    function textAreaAdjust(o) {
        o.style.height = "1px"
        o.style.height = (15+o.scrollHeight)+"px";
    }


    function updateDateDisplay() {
        let elecDateBoxes = $('.electronic_file_dates input');
        elecDateBoxes.prop('disabled', true);
        if ($('#radio_electronic_file').is(':checked')) {
            elecDateBoxes.prop('disabled', false);
            $('.manual_grading_dates input').prop('disabled', $('#no_ta_grade').is(':checked'));
            $('#date_team_lock').prop('disabled', {{ gradeable.isTeamAssignment() ? 'false' : 'true' }});
            $('#late_days').prop('disabled', $('#no_late_submission').is(':checked'));

            {# Use this 'each' trick since 'no_regrade_allowed' may not be defined if grade inquiries are not enabled #}
            let regradeReqDate = $('#date_regrade_request');
            regradeReqDate.prop('disabled', true);
            $('#no_regrade_allowed').each(function () {
                regradeReqDate.prop('disabled', $(this).is(':checked'));
            });
        }
        $('#hide_dates').hide();
        $('#show_all_dates').show();
    }

    //
    // Event Handlers
    //
    function onGradeableTypeChange() {
        // Hide red text once user selects an option
        if($('#radio_electronic_file').is(':checked') ||
           $('#radio_checkpoints').is(':checked') ||
           $('#radio_numeric').is(':checked')) {
               $('#required_type').hide();
        }

        if(!$('#radio_electronic_file').is(':checked')) {
            $('input[name=scanned_exam]').prop('checked', false);
        }

        disableElementChildren('.electronic_file');
        disableElementChildren('.checkpoints');
        disableElementChildren('.numeric');

        // Display the correct options for all forms depending
        //  on gradeable type
        if($('#radio_electronic_file').is(':checked')) {
            disableElementChildren('.electronic_file', false);
            $('#page_1_nav').show();
            onManualGradingChange();
            if ($('input[name=electronic_gradeable_presets]:checked').length === 0) {
                $('input[name=electronic_gradeable_presets][value=normal]').prop('checked', true);
            }
        }
        else {
            $('input[name=electronic_gradeable_presets]').prop('checked', false);
            if ($('#radio_checkpoints').is(':checked')) {
                disableElementChildren('.checkpoints', false);
            }
            else if ($('#radio_numeric').is(':checked')) {
                disableElementChildren('.numeric', false);
            }
        }
    }

    function onTeamAssignmentChange() {
        if($('#team_yes_radio').is(':checked')) {
            // $('.team_yes').show();
            disableElementChildren('.team_yes', false);
            disableElementChildren('.team_no', true);

            // If Set-URL is checked but then teams are disabled
            //  set This-Gradeable as checked instead
            if($('#vcs_radio_submitty_hosted_set_url').is(':checked')) {
                $('#vcs_radio_submitty_hosted').prop('checked', true);
                onVCSTypeChange();
            }
        }
        else {
            // $('.team_yes').hide();
            disableElementChildren('.team_yes', true);
            disableElementChildren('.team_no', false);
        }
    }

    function onDiscussionChange() {
        if($('#yes_discussion').is(':checked')) {
            disableElementChildren('.discussion_id_wrapper', false);
        }
        else {
            disableElementChildren('.discussion_id_wrapper', true);
        }
    }

    function onManualGradingChange() {
        if($('#yes_ta_grade').is(':checked') || !$('#radio_electronic_file').is(':checked')) {
            // $('.manual_grading').show();
            disableElementChildren('.manual_grading', false);
            disableElementChildren('.no_manual_grading', true);
            $('#regrade_request_enable_container').show();
            $('#discussion_grading_enable_container').show();
        }
        else {
            // $('.manual_grading').hide();
            disableElementChildren('.manual_grading', true);
            disableElementChildren('.no_manual_grading', false);
            $('#regrade_request_enable_container').hide();
            $('#discussion_grading_enable_container').hide();
        }
        updateDateDisplay();
    }

    function onVCSTypeChange() {
        disableElementChildren('[name=vcs_content]', true);

        if($('#vcs_radio_submitty_hosted').is(':checked')) {
            disableElementChildren('#vcs_submitty_url_content', false);
        }

        if($('#vcs_radio_submitty_hosted_set_url').is(':checked')) {
            disableElementChildren('#vcs_submitty_set_url_content', false);
            $('#vcs_submitty_url').prop('required', true);
        }
        else {
            $('#vcs_submitty_url').prop('required', false);
        }
    }

    function onIsRegradeAllowedChange() {
        if ($('#yes_regrade_allowed').is(':checked')) {
            //   $('.regrade_request_date').hide();
            disableElementChildren('.regrade_request_date', false);
            disableElementChildren('.grade_inquiry_per_component_allowed', false);
        }
        else {
            //   $('.regrade_request_date').show();
            disableElementChildren('.regrade_request_date', true);
            $('#no_grade_inquiry_per_component_allowed').prop('checked',true);
            disableElementChildren('.grade_inquiry_per_component_allowed', true);
        }
        updateDateDisplay();
    }

    function onLateSubmissionAllowedChanged() {
        let lateSubmissionParts = $('.yes-late-submission');
        if($('#yes_late_submission').is(':checked')) {
            lateSubmissionParts.show();
        }
        else {
            lateSubmissionParts.hide();
        }
        updateDateDisplay();
    }

    $(function () {
        $("#alert-message").dialog({
            modal: true,
            autoOpen: false,
            buttons: {
                Ok: function () {
                    $(this).dialog("close");
                }
            }
        });
    });

    $(document).ready(function() {

        onManualGradingChange();
        $('[name="ta_grading"]').change(onManualGradingChange);

        //
        // Template Selector Box Events
        //

        // Event handler for the gradeable template selection change
        $('[name="gradeable_template"]').change(
        function() {
            // Redirect user to the same page, but in the process,
            //  fetch the data from the template gradeable
            window.location.href = buildCourseUrl(['gradeable']) + `?template_id=${this.value}`;
        });

        //
        // Gradeable Type Radio Button Events
        //

        // Hide team settings if it isn't a electronic gradeable
        onGradeableTypeChange();
        $('[name="type"]').change(onGradeableTypeChange);

        // Hide team settings if team's are not the selected option
        onTeamAssignmentChange();
        $('[name="team_assignment"]').change(onTeamAssignmentChange);

        // Hide VCS settings depending on different radio buttons
        onVCSTypeChange();
        $('[name="vcs_radio_buttons"]').change(onVCSTypeChange);

        onDiscussionChange();
        $('[name="discussion_based"]').change(onDiscussionChange);

        disableElementChildren('#repository', $('input[name=vcs]').val() === 'false');

        // Update the electronic file subtype
        $('input[name=electronic_gradeable_presets]').change(function() {
            $('#radio_electronic_file').prop('checked', true);
            onGradeableTypeChange();
            let vcs = $('input[name=vcs]');
            let scannedExam = $('input[name=scanned_exam]');

            vcs.val('false');
            $('#repository').hide();
            if ($(this).val() === 'scanned_exam') {
                scannedExam.val('true');
            }
            else {
                scannedExam.val('false');
                if ($(this).val() === 'vcs') {
                    vcs.val('true');
                    $('#repository').show();
                }
                else {
                }
            }
            vcs.change();
            scannedExam.change();
        });

        //Hide Grade Inquiry Date if Grade Inquiries are not enabled
        onIsRegradeAllowedChange();
        $('[name="regrade_allowed"]').change(onIsRegradeAllowedChange);

        onLateSubmissionAllowedChanged();
        $('input[name=late_submission_allowed]').change(onLateSubmissionAllowedChanged);
    });

    function checkForm() {
        var gradeable_id = $('#g_id').val();
        var gradeable_title = $('#g_title').val();
        var has_space = gradeable_id.includes(" ");
        var test = /^[a-zA-Z0-9_-]*$/.test(gradeable_id);

        var check1 = $('#radio_electronic_file').is(':checked');
        var check2 = $('#radio_checkpoints').is(':checked');
        var check3 = $('#radio_numeric').is(':checked');


        {% if action != 'edit' %}
            var all_gradeable_ids = {{ template_list|json_encode|raw }};
            if(all_gradeable_ids.find(element => element.g_id === gradeable_id)) {
                alert("Gradeable already exists");
                return false;
            }
        {% endif %}
        if (!test || has_space || gradeable_id == "" || gradeable_id === null) {
            $( "#alert-message" ).dialog( "open" );
            return false;
        }

        if (gradeable_title == '' || gradeable_title === null) {
            alert("A name for the gradeable must be assigned");
            return false;
        }

        if(!check1 && !check2 && !check3) {
            alert("A type of gradeable must be selected");
            return false;
        }

        return true;
    }

</script>
